local skel = fk.CreateSkill {
  name = "emo__yinren",
  dynamic_desc = function (self, player, lang)
    if player:getMark("emo__yinren_levelup") ~= 0 then
      return "emo__yinren_levelup"
    end
  end,
}

Fk:loadTranslationTable{
  ["emo__yinren"] = "音刃",
  [":emo__yinren"] = "出牌阶段限一次，你可以摸一张【杀】，此【杀】造成伤害后，你获得一点护甲。你的【杀】视为无花色。",
  [":emo__yinren_levelup"] = "出牌阶段限一次，你可以摸一张【杀】，此【杀】造成伤害后，你获得一点护甲，并令受伤害的角色翻至背面。你的【杀】视为无花色。",

  ["#emo__yinren-prompt"] = "音刃：你可以摸一张【杀】，此【杀】造成伤害后，你获得一点护甲",
  ["@@emo__yinren-inhand"] = "音刃",
}

skel:addEffect("active", {
  anim_type = "support",
  prompt = "#emo__yinren-prompt",
  times = function (self, player)
    return 1 - player:usedSkillTimes(skel.name, Player.HistoryPhase)
  end,
  can_use = function(self, player)
    return player:usedSkillTimes(skel.name, Player.HistoryPhase) == 0
  end,
  card_num = 0,
  card_filter = Util.FalseFunc,
  target_num = 0,
  on_use = function(self, room, effect)
    local player = effect.from
    local cards = room:getCardsFromPileByRule("slash")
    if #cards == 0 then return end
    local id = cards[1]
    room:obtainCard(player, id, true, fk.ReasonJustMove, player, skel.name, "@@emo__yinren-inhand")
  end,
})

skel:addEffect("filter", {
  card_filter = function(self, to_select, player)
    return player:hasSkill(skel.name) and to_select.trueName == "slash" and
    table.contains(player.player_cards[Player.Hand], to_select.id)
  end,
  view_as = function(self, _, to_select)
    local card = Fk:cloneCard(to_select.name, Card.NoSuit, to_select.number)
    card.skillName = skel.name
    return card
  end,
})

skel:addEffect(fk.Damage, {
  mute = true,
  is_delay_effect = true,
  can_trigger = function(self, event, target, player, data)
    if player == target and not player.dead and data.card then
      local useEvent = player.room.logic:getCurrentEvent():findParent(GameEvent.UseCard)
      if useEvent then
        local use = useEvent.data
        return use.card == data.card and use.extra_data and use.extra_data.emo__yinren_slash
      end
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    player.room:changeShield(player, 1)
    if data.to:isAlive() and player:getMark("emo__yinren_levelup") > 0 and data.to.faceup then
      data.to:turnOver()
    end
  end,
})

skel:addEffect(fk.PreCardUse, {
  can_refresh = function(self, event, target, player, data)
    return target == player and data.card.trueName == "slash" and data.card:getMark("@@emo__yinren-inhand") ~= 0
  end,
  on_refresh = function(self, event, target, player, data)
    data.extra_data = data.extra_data or {}
    data.extra_data.emo__yinren_slash = true
  end,
})



return skel
